home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_300
/
331_01
/
pcio.asm
< prev
next >
Wrap
Assembly Source File
|
1990-06-10
|
34KB
|
1,229 lines
; pcio
; Most of these routines should not be called directly by the application.
; Routines are being added in term.c which relay the call to here. In that
; way terminal specific functions will be consolidated in term.c. By
; changing just term.c the program can be adapted to a different host,
; resulting in better portability. Many of the routines contained here
; are unused, but may be useful for other applications. Many of these
; functions could also be implemented mostly in C. Some assembly language
; is essential for speed on slow systems, but it becomes less important
; on fast processors, and may eventually have to go away altogether for
; better portability. The standard BIOS video calls are incredibly slow,
; and are mostly unused here. On an 80386 system the screen refresh time
; is less than the keyboard autorepeat time with the interface in this
; file.
;
; May 87 G. Osborn
; Converted from DeSmet to the Microsoft version 3.0 macro
; assembler format. Microsoft does not follow data labels
; by a colon. Code segment labels are followed by a colon, though.
; Changed "byte" to "byte ptr" throughout.
; Changed calling sequence to that of Microsoft C compiler version 3.0.
; Same as DeSmet except SI and DI must be saved in case register
; variables are used, so the new sequence is compatible with both compilers.
; publics are defined two ways for compiler compatibility. Each is
; defined as _LABEL (Microsoft) and LABEL_ (DeSmet).
; Effort required to reconvert to DeSmet is minor
; 2-18-87 G. Osborn
_TEXT SEGMENT BYTE PUBLIC 'CODE'
; instructions
_TEXT ENDS
CONST SEGMENT WORD PUBLIC 'CONST'
; read only constants. not constant strings.
CONST ENDS
_BSS SEGMENT WORD PUBLIC 'BSS'
; uninitialized static data
_BSS ENDS
_DATA SEGMENT WORD PUBLIC 'DATA'
; initialized global and static data
_DATA ENDS
DGROUP GROUP CONST, _BSS, _DATA
ASSUME CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP
;------------------------------------------------------------------
; pcio.a -- Screen and keyboard interface routines for the PC
; Specific to DeSmet C
;
; last modified - 08/06/86
;
;
; !!! PLEASE NOTE !!!
; This is not quite the same as pcio.a from DeSmet -
; I've made some changes here and there for use with ged.
; Am slowly changing all Desmet functions that use x,y co-ords
; to work as col,row - but have not finished
; Mel Tearle
;------------------------------------------------------------------
;------------------------------------------------------------------
; data starts here
;------------------------------------------------------------------
_DATA SEGMENT
; In this implementation, all special and function keys are translated
; to the following values.
; control key translations. would be better done in C, because the
; convesion time is not critical.
up_char equ 5 ;equ 196 mapped into cursor-pad
down_char equ 24 ;equ 197
left_char equ 19 ;equ 198
right_char equ 4 ;equ 199
bol_char equ 15 ;equ 200
eol_char equ 16 ;equ 201
pageup_char equ 18 ;equ 202
pagedown_char equ 3 ;equ 203
Del_char equ 7 ;equ 207
Ins_char equ 16h
; bof_char equ 204 not used
; eof_char equ 205 not used
; NextWord_char equ 208 not used
; PrevWord_char equ 209 not used
M1 equ 210
M2 equ 211
M3 equ 212
M4 equ 213
M5 equ 214
M6 equ 215
M7 equ 216
M8 equ 217
M9 equ 218
M10 equ 219
M11 equ 220
M12 equ 221
; the table that is used to make the translation
; note - not all used
convert db 72, up_char
db 80, down_char
db 75, left_char
db 77, right_char
db 71, 220 ; <home> becomes beginning of file
db 79, 221 ; <end> becomes end of file
db 73, pageup_char
db 81, pagedown_char
db 113, 222 ; ^<up arrow> .. cursor to top of window
db 118, 223 ; cursor to bottom of window
db 82, Ins_char ; <ins> becomes ^V
db 83, Del_char
db 115, 15h ; ^<left arrow> becomes ^U = cursor full left
db 116, 1Dh ; ^<right arrow> becomes ^] = cursor full right
db 59, M1
db 60, M2
db 61, M3
db 62, M4
db 63, M5
db 64, M6
db 65, M7
db 66, M8
db 67, M9
db 68, M10
db 69, M11
db 70, M12
db 0, 255 ; illegal character
; equates for bios interface.
; the interrupt and codes for the screen interface interrupt.
video equ 10h ;interrupt for dealing with screen
mode equ 0 ;code for setting new screen mode
curtype equ 1 ;code for setting new cursor type
setcur equ 2 ;code for addressing cursor
readcur equ 3 ;code for reading cursor location
readlp equ 4 ;code for reading light pen position
setpage equ 5 ;code to select active page
scrollup equ 6 ;code to scroll screen up
scrolldn equ 7 ;code to scroll screen nown
readch equ 8 ;code to read a character from screen
writeach equ 9 ;code to write char and attributes
writech equ 10 ;code to write character only
setpal equ 11 ;code to set new setpal or border
wdot equ 12 ;code to write a dot
rdot equ 13 ;code to read a dot
wtty equ 14 ;code to write as if teletype
state equ 15 ;code to find current screen status
; int 10 (video) changes all registers except cs,ss,ds,es,bx,cx,dx
; used in set_video
mono_adr equ 0b000h ;mono adapter
graph_adr equ 0b800h ;graphics adapter*
vadrs dw 0
; the interrupt and codes for the keyboard interface.
keyboard equ 16h ;interrupt 16 to deal with keyboard
cicode equ 0 ;code for reading a character
cstscode equ 1 ;code for keyboard status
; caution: must change column number if 40 column mode
crt_cols equ 80
; variables available to a C88 program
public scr_cols_, scr_rows_, scr_scrollup_, scr_scrolldown_
public scr_mode_, scr_page_, scr_attr_, scr_window_top_
public _scr_cols, _scr_rows, _scr_scrollup, _scr_scrolldown
public _scr_mode, _scr_page, _scr_attr, _scr_window_top
_scr_cols label byte
scr_cols_ db crt_cols ;current number of columns
; note- make 25 for ms-dos and 24 for cp/m as cp/m steals the bottom
; line.
scr_rows equ 25
_scr_rows label byte
scr_rows_ db scr_rows ;current number of rows, for ged, was 25
_scr_mode label byte
scr_mode_ db 0 ;current screen mode
_scr_page label byte
scr_page_ db 0 ;current page
_scr_attr label byte
scr_attr_ db 7 ;current attributes for screen
;7 is white letters on black
_scr_window_top label byte
scr_window_top_ db 1 ;first line to scroll, was 0
; variables needed by SEE. Not used here.
_scr_scrollup label byte
scr_scrollup_ db 0 ;zero if scrollup leaves top line alone
_scr_scrolldown label byte
scr_scrolldown_ db 0 ;zero if scroll down supported
_DATA ENDS
;------------------------------------------------------------------
; code starts here
;------------------------------------------------------------------
_TEXT SEGMENT
PUBLIC _scr_setup
;-------------------------------------------------------------------------
; SCR_SETUP_ scr_setup must be called before any use of any
; other routine unless the starting mode is 80X25
; character mode (3,4 or 7). Must be called for monochrome
; (mode 7) for scr_cu